package com.gem.mapper;

import com.gem.domain.Campus;
import com.gem.domain.Company;
import com.github.pagehelper.PageInfo;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @Author: 玲
 * @Description: 企业客户接口
 * @create 2019-10-24 14:19
 * @Modified By:
 */
@Mapper
public interface CompanyMapper {

    //查询所有企业
    @Select("select t1.*,t2.sname from (select c.* , u.personname cname from company c,user u where c.co_career = u.uid ) t1,\n" +
            " (select c.co_id, u.personname sname from company c,user u where c.co_seller = u.uid ) t2 where t1.co_id=t2.co_id and t1.co_status > 0")
    List<Company> findAll();

    //根据id查企业
    @Select("select t1.*,t2.sname from (select c.* , u.personname cname from company c,user u where c.co_career = u.uid ) t1,\n" +
            " (select c.co_id, u.personname sname from company c,user u where c.co_seller = u.uid ) t2 where t1.co_id=t2.co_id  and t1.co_id = #{coId} and t1.co_status > 0")
    Company findById(Integer coId);

    //搜索企业
    List<Company> search(Company company);

    //保存企业信息
    Integer save(Company company);

    //更新企业信息
    Integer update(Company company);

    //根据id伪删除
    @Update("update company set co_status = -1 where co_id = #{coId}")
    Integer deleteById(Integer coId);

    //伪删除所选
    Integer deleteAll(int [] coIds);

    //excel
    @Select("SELECT * FROM company WHERE co_name = #{stringCellValue} AND co_status > 0")
    Company findByName(String stringCellValue);

    @Select("select t1.*,t2.sname from (select c.* , u.personname cname from company c,user u where c.co_career = u.uid and u.job = '就业') t1,\n" +
            " (select c.co_id, u.personname sname from company c,user u where c.co_seller = u.uid and u.job = '企培') t2 where t1.co_id=t2.co_id and t1.co_name = #{coName} and t1.co_status > 0")
    List<Company> findBycoName(@Param("coName") String coName);
}
